package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.PopulationFixedBean;
import com.sx.zongzhi.bean.PopulationFixedSearchBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IPopFixedView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取留守人员列表
 */
public class PopFixedPest {

    private IPopFixedView fixedView;

    public PopFixedPest(IPopFixedView fixedView) {
        this.fixedView=fixedView;
    }


    /**
     *
     * @param orgId 网格id
     * @param page 当前页
     * @param rows 当前行
     */
    public void getPopFixedList(String path, String orgId, PopulationFixedSearchBean searchBean,
                                int page, int rows){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("orgId", orgId);
        if (searchBean!=null){
            map.put("searchLeftBehindPeopleVo.name", searchBean.getName());
            map.put("searchLeftBehindPeopleVo.idCardNo", searchBean.getIdCardNo());
            map.put("searchLeftBehindPeopleVo.currentAddress", searchBean.getCurrentAddress());
            map.put("searchLeftBehindPeopleVo.isEmphasis", searchBean.getIsEmphasis());
            map.put("searchLeftBehindPeopleVo.isDeath", searchBean.getIsDeath());
            map.put("searchLeftBehindPeopleVo.gender.id", searchBean.getGender());
            map.put("searchLeftBehindPeopleVo.nation", searchBean.getNation());
            map.put("searchLeftBehindPeopleVo.maritalState", searchBean.getMaritalState());
            map.put("searchLeftBehindPeopleVo.politicalBackground", searchBean.getPoliticalBackground());
            map.put("searchLeftBehindPeopleVo.schoolStr", searchBean.getSchoolStr());
            map.put("searchLeftBehindPeopleVo.leftRelationship.id", searchBean.getLeftRelationship());
            map.put("searchLeftBehindPeopleVo.leftType.id", searchBean.getLeftType());
            map.put("searchLeftBehindPeopleVo.birthday", searchBean.getBirthday());
            map.put("searchLeftBehindPeopleVo.endBirthday", searchBean.getEndBirthday());
        }
        map.put("page",page);
        map.put("rows", rows);

        new CollectManager().getPopFixedList(path,map, new BaseCallBack<BaseResult<PopulationFixedBean>>() {
            @Override
            public void onSuccess(BaseResult<PopulationFixedBean> response) {
                fixedView.getPopFixedList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                fixedView.showError(message);
            }
        });
    }

}
